﻿using MediatR;
using SheepCultivation.Common.Domain.SheepBasicInformation;
using SheepCultivation.Common.Domain.Week2;
using SheepCultivation.Common.Dto;
using SheepCultivation.Common.Infrastructure.Interface;
using SheepCultivation.Enum;

namespace SheepCultivation.API.AddliCation.Reportw
{
    public class ReportEarSeachHandler : IRequestHandler<ReportEarSeachCommon, Result>
    {
        public readonly IBaseRepository<Building> BuildingRepository;
        public readonly IBaseRepository<BasicInformation> BasicInformationRepository;
        public readonly IBaseRepository<Sheepbreed> SheepbreedRepository;

        public ReportEarSeachHandler(IBaseRepository<Building> buildingRepository, IBaseRepository<BasicInformation> basicInformationRepository, IBaseRepository<Sheepbreed> sheepbreedRepository)
        {
            BuildingRepository = buildingRepository;
            BasicInformationRepository = basicInformationRepository;
            SheepbreedRepository = sheepbreedRepository;
        }

        public async Task<Result> Handle(ReportEarSeachCommon request, CancellationToken cancellationToken)
        {
            var res = new Result() { Code = (int)CommonEnumCode.error };
            try
            {
                var list = BasicInformationRepository.GetAll().ToList();
                res.Data = list;
                res.Code = (int)CommonEnumCode.success;
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
